capture cd "/Users/Alex/Dropbox/Stubbs/FAUST/Submitted/GP_final/GP_replication"
use "KentikelenisStubbs_2021_GlobalPolicy_Dataset.dta", clear 
* ==============================================================================
* Generate variables
* ==============================================================================
encode cname, gen(cid)
xtset cid year
egen cm_ggx_ngdp_10_19 = mean(ggx_ngdp) if year>=2010 & year<=2019, by(cname)
egen m_hic_ggx_ngdp_10_19 = mean(ggx_ngdp) if year>=2010 & year<=2019 & HIC==1
egen m_mic_ggx_ngdp_10_19 = mean(ggx_ngdp) if year>=2010 & year<=2019 & MIC==1
egen m_lic_ggx_ngdp_10_19 = mean(ggx_ngdp) if year>=2010 & year<=2019 & LIC==1
gen dif_ggx_ngdp_23_10s = ggx_ngdp_Oct2021 - l4.cm_ggx_ngdp_10_19 if year==2023
gen L4cm_ggx_ngdp_10_19 = l4.cm_ggx_ngdp_10_19
foreach var of varlist ggx_ngdp* ggr_ngdp* {
	egen m_hic_`var' = mean(`var') if HIC==1, by(year)
	egen m_mic_`var' = mean(`var') if MIC==1, by(year)
	egen m_lic_`var' = mean(`var') if LIC==1, by(year)
}
gen debtservb_btot = (debtserv_ba + debtserv_bi)/1000000000
lab var debtservb_btot "PPG, bilateral debt service (billions USD)"
gen debtservb_mtot = (debtserv_ma + debtserv_mi)/1000000000
lab var debtservb_mtot "PPG, multilateral debt service (billions USD)"
gen debtservb_ptot = (debtserv_pa + debtserv_pi)/1000000000
lab var debtservb_ptot "PPG, private debt service (billions USD)"
gen debtservb_tot = debtserv_tot/1000000000
lab var debtservb_tot "PPG, total debt service (billions USD)"
gen dsrbtot_gdp = 100*debtservb_btot/ngdpd_Oct2021
replace dsrbtot_gdp = 100*debtservb_btot/ngdpd if year<2021
lab var dsrbtot_gdp "PPG, bilateral debt service (% of GDP)"
gen dsrmtot_gdp = 100*debtservb_mtot/ngdpd_Oct2021
replace dsrmtot_gdp = 100*debtservb_mtot/ngdpd if year<2021
lab var dsrmtot_gdp "PPG, multilateral debt service (% of GDP)"
gen dsrptot_gdp = 100*debtservb_ptot/ngdpd_Oct2021
replace dsrptot_gdp = 100*debtservb_ptot/ngdpd if year<2021
lab var dsrptot_gdp "PPG, private debt service (% of GDP)"
gen dsrtot_gdp = 100*debtservb_tot/ngdpd_Oct2021
replace dsrtot_gdp = 100*debtservb_tot/ngdpd if year<2021
lab var dsrtot_gdp "PPG, total debt service (% of GDP)"
gen ggr_usd = ngdpd_Oct2021 * (ggr_ngdp_Oct2021/100)
replace ggr_usd = ngdpd * (ggr_ngdp/100) if year<2021
lab var ggr_usd "General government revenue (billions USD)"
gen dsrbtot_rev = 100*debtservb_btot/ggr_usd
lab var dsrbtot_rev "PPG, bilateral debt service (% of revenues)"
gen dsrmtot_rev = 100*debtservb_mtot/ggr_usd
lab var dsrmtot_rev "PPG, multilateral debt service (% of revenues)"
gen dsrptot_rev = 100*debtservb_ptot/ggr_usd
lab var dsrptot_rev "PPG, private debt service (% of revenues)"
gen dsrtot_rev = 100*debtservb_tot/ggr_usd
lab var dsrtot_rev "PPG, total debt service (% of revenues)"
* ==============================================================================
* Factual statements
* ==============================================================================
xtset cid year
* "Indeed, 83 countries are expected to face fiscal contractions by 2023 (i.e., they will be spending less than their 2010s average), thereby exposing a cumulative total of 2.3 billion people to the socio-economic consequences of budget cuts."
count if dif_ggx_ngdp_23_10s>=0 & year==2023 & !missing(dif_ggx_ngdp_23_10s)
count if dif_ggx_ngdp_23_10s>=-1 & dif_ggx_ngdp_23_10s<0 & year==2023 & !missing(dif_ggx_ngdp_23_10s)
count if dif_ggx_ngdp_23_10s<-1 & year==2023 & !missing(dif_ggx_ngdp_23_10s)
count if dif_ggx_ngdp_23_10s<0 & year==2023 & !missing(dif_ggx_ngdp_23_10s)
egen POP = total(lp) if f3.dif_ggx_ngdp_23_10s <0 & !missing(f3.dif_ggx_ngdp_23_10s)
sum POP
drop POP
* "First, high-income countries ... increased their year-on-year government spending by an unprecedented 7.5% of GDP. Per IMF projections, these expenditures will be adjusted downwards from 2021 onwards, and by 2024 are expected to revert to their average for the 2010s."
list cname year m_hic_ggx_ngdp d.m_hic_ggx_ngdp m_hic_ggx_ngdp_Oct2021 d.m_hic_ggx_ngdp_Oct2021 m_hic_ggx_ngdp_10_19 if HIC==1
* "For middle income countries, we observe that the slow process of increasing public expenditures over the past decade will reverse. These countries increased government spending by approximately 3.2% of GDP in 2020 but are expected to rapidly scale back: by 2023, they will already be spending less than their average for the 2010s, with further reductions projected for subsequent years."
list cname year m_mic_ggx_ngdp d.m_mic_ggx_ngdp m_mic_ggx_ngdp_Oct2021 d.m_mic_ggx_ngdp_Oct2021 m_mic_ggx_ngdp_10_19 if MIC==1
* "In contrast, low-income countries will experience a milder fiscal contraction, although their levels of government spending were very low to begin with and stagnant throughout the 2010s. The pandemic-related increase in government spending (1.5% of GDP) will much more gradually be phased out: by 2025, these countries are expected to revert to their average for the 2010s."
list cname year m_lic_ggx_ngdp d.m_lic_ggx_ngdp m_lic_ggx_ngdp_Oct2021 d.m_lic_ggx_ngdp_Oct2021 m_lic_ggx_ngdp_10_19 if LIC==1
* "For example, Jordan’s government spent on average 32.4% of GDP over the 2010s (close to the mean for MICs), while their spending is only expected to be 30.5% by 2023; we classify this 1.9-percentage point decrease as an instance of aggressive austerity."
sum L4cm_ggx_ngdp_10_19 if MIC==1
list cname L4cm_ggx_ngdp_10_19 ggx_ngdp_Oct2021 dif_ggx_ngdp_23_10s if year==2023 & cname=="Jordan"
* "In line with the evidence presented above, high-income countries are generally projected to be spending more by 2023 than they did over the 2010s: over half of these countries (36 out of 64) will have government expenditure that exceeds their pre-Covid average, eight will have moderate spending reductions, and the remaining 20 countries will experience aggressive austerity."
count if HIC==1 & year==2023 & !missing(dif_ggx_ngdp_23_10s)
count if dif_ggx_ngdp_23_10s>=0 & HIC==1 & year==2023 & !missing(dif_ggx_ngdp_23_10s)
count if dif_ggx_ngdp_23_10s>=-1 & dif_ggx_ngdp_23_10s<0 & HIC==1 & year==2023 & !missing(dif_ggx_ngdp_23_10s)
count if dif_ggx_ngdp_23_10s<-1 & HIC==1 & year==2023 & !missing(dif_ggx_ngdp_23_10s)
count if missing(dif_ggx_ngdp_23_10s) & HIC==1 & year==2023
* "Similarly, most low-income countries are also expected to expand: 13 will follow an expansionary path, three will experience moderate consolidation, and the remaining eight will pursue aggressive austerity. Almost all of the 11 contracting countries are in Africa (excluding Haiti, Tajikistan, and Yemen), and most are also classified by the World Bank as being in ‘fragile and conflict affected situations,’ which might also account for the fiscal problems they are facing. "
count if LIC==1 & year==2023 & !missing(dif_ggx_ngdp_23_10s)
count if dif_ggx_ngdp_23_10s>=0 & LIC==1 & year==2023 & !missing(dif_ggx_ngdp_23_10s)
count if dif_ggx_ngdp_23_10s>=-1 & dif_ggx_ngdp_23_10s<0 & LIC==1 & year==2023 & !missing(dif_ggx_ngdp_23_10s)
count if dif_ggx_ngdp_23_10s<-1 & LIC==1 & year==2023 & !missing(dif_ggx_ngdp_23_10s)
count if missing(dif_ggx_ngdp_23_10s) & LIC==1 & year==2023
list cname ccode subregion_UN if dif_ggx_ngdp_23_10s<=0 & LIC==1 & year==2023 & !missing(dif_ggx_ngdp_23_10s)
* "In contrast to the high prevalence of fiscal expansion among high- and low-income countries, data on the 101 middle-income countries show more diversity: 57 are expected to maintain an expansionary fiscal trajectory, eight will experience a moderate contraction, and the remaining 36 countries will witness aggressive austerity. Over half of the middle-income countries of Africa and South-East Asia are expected to implement extensive budget cuts."
count if MIC==1 & year==2023 & !missing(dif_ggx_ngdp_23_10s)
count if dif_ggx_ngdp_23_10s>=0 & MIC==1 & year==2023 & !missing(dif_ggx_ngdp_23_10s)
count if dif_ggx_ngdp_23_10s>=-1 & dif_ggx_ngdp_23_10s<0 & MIC==1 & year==2023 & !missing(dif_ggx_ngdp_23_10s)
count if dif_ggx_ngdp_23_10s<-1 & MIC==1 & year==2023 & !missing(dif_ggx_ngdp_23_10s)
count if missing(dif_ggx_ngdp_23_10s) & MIC==1 & year==2023
count if MIC==1 & region_UN=="Africa" & year==2023 & !missing(dif_ggx_ngdp_23_10s)
count if MIC==1 & dif_ggx_ngdp_23_10s<-1 & region_UN=="Africa" & year==2023 & !missing(dif_ggx_ngdp_23_10s)
count if MIC==1 & subregion_UN=="South-eastern Asia" & year==2023 & !missing(dif_ggx_ngdp_23_10s)
count if MIC==1 & dif_ggx_ngdp_23_10s<-1 & subregion_UN=="South-eastern Asia" & year==2023 & !missing(dif_ggx_ngdp_23_10s)
list cname lp_Oct2021 if dif_ggx_ngdp_23_10s<-1 & MIC==1 & year==2023 & !missing(dif_ggx_ngdp_23_10s)
list cname lp_Oct2021 if dif_ggx_ngdp_23_10s>=0 & MIC==1 & year==2023 & !missing(dif_ggx_ngdp_23_10s)
list cname lp_Oct2021 if dif_ggx_ngdp_23_10s>=-1 & dif_ggx_ngdp_23_10s<0 & MIC==1 & year==2023 & !missing(dif_ggx_ngdp_23_10s)
* "For example, Indonesia had an average of government spending at 17.5% of GDP over the 2010s, already very low compared to the average of middle-income countries. Between 2019 and 2020, this jumped by 1.6 percentage points as the pandemic emerged; by 2023, the country's government expenditure is expected to be at 15.2%, or 2.3 percentage points lower than the 2010s average""
list cname year ggx_ngdp d.ggx_ngdp L4cm_ggx_ngdp_10_19 ggx_ngdp_Oct2021 dif_ggx_ngdp_23_10s if cname=="Indonesia"
* "The left panel presents average debt service in billions of US dollars. It shows the average middle-income country must pay $3.68bn on external debt service, $2.49bn (68%) of which is to the private sector—although these values are strongly influenced by large economies such as Mexico ($36.88bn private repayments out of $40.59bn total debt service), China ($31.88bn of $37.24bn), and Russia ($19.24bn of $19.41bn)."
sum debtservb_tot debtservb_btot debtservb_mtot debtservb_ptot if year==2021 & LIC==0
sort debtservb_tot
list cname year debtservb_ptot debtservb_tot if year==2021 & LIC==0
* "The average low-income country pays $0.31bn in debt service, but only $0.05bn (16%) is to the private sector, with the bulk made up of bilateral and multilateral repayments."
sum debtservb_tot debtservb_btot debtservb_mtot debtservb_ptot if year==2021 & LIC==1
* "For the average middle-income country, debt service is 15.2% of revenues, of which 5.1% of revenues is to the private sector; for the average low-income country it is 11.3% and 0.90% of revenues respectively."
sum dsrtot_rev dsrbtot_rev dsrmtot_rev dsrptot_rev if year==2021 & LIC==0
sum dsrtot_rev dsrbtot_rev dsrmtot_rev dsrptot_rev if year==2021 & LIC==1
* "In particular, middle-income countries spent 2.8% of GDP on health in 2018, compared with an expected 3.7% of GDP on external debt service in 2021; for low-income countries, these figures are 1.1% and 1.7% of GDP respectively."
sum dsrtot_gdp dsrbtot_gdp dsrmtot_gdp dsrptot_gdp if year==2021 & LIC==0
sum dsrtot_gdp dsrbtot_gdp dsrmtot_gdp dsrptot_gdp if year==2021 & LIC==1
* ==============================================================================
* Figure 1. Government expenditure in high-, middle- and low-income countries
* ==============================================================================
twoway (scatter m_hic_ggx_ngdp year if year>=2010 & year<=2020, sort(year) connect(l) msymbol(i) lwidth(thick))  (lfit m_hic_ggx_ngdp year if year>=2010 & year<=2019, sort(year) connect(l) msymbol(i) lpattern(dash)) (scatter m_hic_ggx_ngdp_Oct2021 year if year>=2019 & year<=2025, sort(year) connect(l) msymbol(square)) (scatter m_mic_ggx_ngdp year if year>=2010 & year<=2020, sort(year) connect(l) msymbol(i) lwidth(thick))  (lfit m_mic_ggx_ngdp year if year>=2010 & year<=2019, sort(year) connect(l) msymbol(i) lpattern(dash)) (scatter m_mic_ggx_ngdp_Oct2021 year if year>=2019 & year<=2025, sort(year) connect(l) msymbol(square))  (scatter m_lic_ggx_ngdp year if year>=2010 & year<=2020, sort(year) connect(l) msymbol(i) lwidth(thick)) (lfit m_lic_ggx_ngdp year if year>=2010 & year<=2019, sort(year) connect(l) msymbol(i) lpattern(dash)) (scatter m_lic_ggx_ngdp_Oct2021 year if year>=2019 & year<=2025, sort(year) connect(l) msymbol(square)) , graphregion(fcolor(white)) legend(row(2)) ytitle(Government expenditure (% of GDP)) ylabel(, angle(horizontal)) title("") legend(size(small) rows(3) label(1 "HIC spending") label(2 "HIC trend 2010-19") label(3 "HIC projection") label(4 "MIC spending") label(5 "MIC trend 2010-19") label(6 "MIC projection") label(7 "LIC spending") label(8 "LIC trend 2010-19") label(9 "LIC projection"))
graph export "GP_Figure1.png", replace width(4000)
* ==============================================================================
* Figure 2. Government expenditure changes as a share of GDP, 2010s vs 2023
* ==============================================================================
preserve
*** get the shapefiles in order
capture cd "GIS"
spshape2dta "World_Countries__Generalized_.shp", replace saving(world)
*** explore the outline file
use world_shp, clear
geo2xy _Y _X, proj (web_mercator) replace
*** merge with attributes file to get the names
merge m:1 _ID using world
drop if COUNTRY=="Antarctica"
drop rec_header- _merge
sort _ID
save, replace
*** merging
use world, clear
ren COUNTRY cname             
drop if cname=="Antarctica"
replace cname="Democratic Republic of the Congo" if cname=="Congo DRC"
replace cname="Hong Kong SAR" if cname==""
replace cname="Islamic Republic of Iran" if cname=="Iran"
replace cname="Korea" if cname=="South Korea"
replace cname="Kosovo" if cname==""
replace cname="Kyrgyz Republic" if cname=="Kyrgyzstan"
replace cname="Lao P.D.R." if cname=="Laos"
replace cname="Macao SAR" if cname==""
replace cname="Republic of Congo" if cname=="Congo"
replace cname="Russia" if cname=="Russian Federation"
replace cname="Slovak Republic" if cname=="Slovakia"
replace cname="St. Kitts and Nevis" if cname=="Saint Kitts and Nevis"
replace cname="St. Lucia" if cname=="Saint Lucia"
replace cname="St. Vincent and the Grenadines" if cname=="Saint Vincent and the Grenadines"
replace cname="São Tomé and Príncipe" if cname=="Sao Tome and Principe"
replace cname="Taiwan Province of China" if cname==""
replace cname="The Bahamas" if cname=="Bahamas"
replace cname="The Gambia" if cname=="Gambia"
replace cname="West Bank and Gaza" if cname=="Palestinian Territory"
merge 1:m cname using "..\KentikelenisStubbs_2021_GlobalPolicy_Dataset.dta"
*** see which countries didn't merge
tab cname if _m==1 
tab cname if _m==2 
*** generate a local for the color scheme
* colorpalette spmap reds, n(4) nograph reverse
* local colors `r(p)'
* return list
encode cname, gen(cid)
xtset cid year
egen cm_ggx_ngdp_10_19 = mean(ggx_ngdp) if year>=2010 & year<=2019, by(cname)
gen dif_ggx_ngdp_23_10s = ggx_ngdp_Oct2021 - l4.cm_ggx_ngdp_10_19 if year==2023
spmap dif_ggx_ngdp_23_10s using world_shp if year==2023, id(_ID) ocolor(black ..) osize(vvthin ..) fcolor("201 48 44" "255 127 0" "66 166 86") legend(pos(7) size(*1)) legtitle("Fiscal adjustment" "(% GDP), 2010s-23") legstyle(2) ndfcolor(gs15 ..) ndlabel("Missing") ndsize(vvthin ..) clmethod(custom) clbreaks(-45 -1 0 30)
graph save "GP_Figure2.gph", replace
graph export "GP_Figure2.png", replace width(4000)
capture cd ..
restore
* ==============================================================================
* Figure 3. External debt service in middle- and low-income countries for 2021
* ==============================================================================
graph bar (mean) debtservb_tot debtservb_btot debtservb_mtot debtservb_ptot if year==2021, over(LIC, relabel (1 "MICs" 2 "LICs")) graphregion(fcolor(white)) legend(lab(1 Total) lab(2 Bilateral) lab(3 Multilateral) lab(4 Private)) ylabel(,angle(horizontal)) ytitle("Average external debt service (billions of USD)") name(g1)
graph bar (mean) dsrtot_rev dsrbtot_rev dsrmtot_rev dsrptot_rev if year==2021, over(LIC, relabel (1 "MICs" 2 "LICs")) graphregion(fcolor(white)) legend(lab(1 Total) lab(2 Bilateral) lab(3 Multilateral) lab(4 Private)) ylabel(,angle(horizontal)) ytitle("Average external debt service (% of revenues)") name(g2)
grc1leg2 g1 g2, graphregion(fcolor(white))
graph export "GP_Figure3.png", replace width(4000)
graph drop _all
* ==============================================================================
* Figure 4. IMF approved funding by type (2 March 2020 to 31 August 2021)
* ==============================================================================
* See Appendix Table 1 
* ==============================================================================
* Appendix Table 1. IMF approved funding by facility (2 March 2020 to 31 August 2021)
* ==============================================================================
preserve
import excel "KentikelenisStubbs_2021_GlobalPolicy_CovidLendingData.xlsx", sheet("Data") firstrow case(lower) clear
gen type2 = typeof
replace type2 = "Extended Credit Facility (ECF)" if typeof=="Augmentation of ECF"
replace type2 = "Extended Fund Facility (EFF)" if typeof=="Augmentation of EFF"
replace type2 = "Flexible Credit Line (FCL)" if typeof=="Augmentation of FCL"
replace type2 = "Stand-By Arrangement (SBA)" if typeof=="Augmentation of SBA"
replace type2 = "Standby Credit Facility (SCF)" if typeof=="Augmentation of SCF"
tabstat amountapprovedinusdmillion, by(type2) s(n sum) labelwidth(32)
by type2 country, sort: gen nvals = _n==1
by type2: replace nvals = sum(nvals)
tabstat nval, by(type2) s(max) nototal
egen x = group(country)
sum x
restore
* ==============================================================================
